
def print_bin(num: int):
    # print(format(num,'032b'))   # 打印 32位的二进制
    # print(f'{num:032b}')    # 打印 32位的二进制

    # print(format(num << 1, '032b'))     # 左移
    # print(format(num >> 1, '032b'))     # 右移
    # print(format(num & (num << 1), '032b'))   # 按位与   对应位都是1，结果是1，否则0
    # print(format(num | (num << 1), '032b'))   # 按位或   对应位有1，结果是1，否则0
    # print(format(num ^ (num << 1), '032b'))   # 按位异或   对应位一个1，一个0，结果是1，否则0

    # 取反码    正数反码，补码都是原码
    # 负数反码：符号位不变，其余取反
    # 负数补码：反码+1
    # print(format(~num,'032b'))

    print(format(num, '032b'))
    print(format(num >> 1, '032b'))
    print(format(num >> 1, '032b'))






if __name__ == '__main__':
    print_bin(-1024)